# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class MashangpaPipeline:

    def process_item(self, item, spider):
        current_array = None
        item = spider.parser.parse_responce(item)
        try:
            current_array = item["current_array"]
        except Exception:
            raise Exception('返回结果非预期：', item)
        print(current_array)
        pipeline_sum = sum(current_array)
        spider.accumulate(pipeline_sum)
        return item